﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace StudioLive
{
    public partial class chat : Form
    {
        //TODO: add comments
        Color chatColor = Color.Red;
        public chat()
        {
            InitializeComponent();
            this.Height = 431;
        }


        private void button1_Click(object sender, EventArgs e)
        {
            if (this.Height > 432) {
                this.Height = 431;
            }
            else
            {
                this.Height += 100;
            }
        }

        private void colorB_Click(object sender, EventArgs e)
        {
            try
            {
                ColorDialog cd = new ColorDialog();
                cd.ShowDialog();
                chatColor = cd.Color;
                colorB.BackColor = cd.Color;
            }
            catch { }
        }

        private void clearChatB_Click(object sender, EventArgs e)
        {
            vars.chatContent = vars.emptyChatContent;
            chatWB.DocumentText = vars.chatContent;
        }

        private void chatTB_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                string code = string.Format("<p><span style='color: RGB({0},{1},{2})'>{3}:</span> {4}</p>", chatColor.R, chatColor.G, chatColor.B, nameTB.Text, chatTB.Text);
                vars.chatContent = code + vars.chatContent;
                chatTB.Text = "";
                chatWB.DocumentText = vars.chatContent;
            }

        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            chatWB.DocumentText = vars.chatContent;
        }
    }
}
